<?php

	// inport the constants
	require_once('dal.php');

	
	// firstly we need to make sure the correct aparams are supplied. 
	
	$long = "";
	$lat = "";
	
	if(!isset($_GET['long']) || !isset($_GET['lat']))
	{
		die("The longtitudional and latidudional values were not supplied.");	
	}else
	{
		$long = $_GET['long'];
		$lat = $_GET['lat'];
	}
	
	// now that we have the lat and long values we can store them to the database with the current time stamp
	
	
	echo(do_report($lat, $long));
	
	
	// the report function
	
	function do_report($latVal, $longVal)
	{
		$dal = new DAL;
		
		$dal->connect_to_db();
		
		$query = "INSERT INTO  `CurrentWarning` (`Index` , latitude` , Longitude` , `Time`) (NULL ,  '" . $latVal . "',  '" . $longVal . "', CURRENT_TIMESTAMP);";
		
		if($result = $dal->execute_query($query))
		{
			return "report sucessfull";
		}else
		{
			return "report did not work";
		}
		
		$dal->disconnect_from_db();
	}
	

?>